package salesforce;

public class TwoStrings {
    public static void towStrings(String[] a, String[] b){
        for (int i = 0; i < a.length; i++) {
            compare2String(a[i], b[i]);
        }
    }

    private static void compare2String(String s1, String s2) {
       int[] map = new int[256];
       char[] ca = s1.toCharArray();
        for (char c : ca) {
            map[c] = 1;
        }

        boolean flag = false;
        for (int i = 0; i < s2.length(); i++) {
            if (map[s2.charAt(i)] == 1) {
                flag = true;
                break;
            }
        }
        if (flag) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

    public static void main(String[] args) {
        String[] a = new String[]{"ab", "cd", "ef"};
        String[] b = new String[]{"af", "ee", "ef"};
        towStrings(a,b);

    }
}
